package controllers;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ActionEvent;

import beans.UserBeanRemote;
import dto.DTOUser;

@ManagedBean
@SessionScoped
public class SelectedUserController {
	
	private Integer sId;
	
	@EJB
	UserBeanRemote ubr;
	
	private DTOUser us;
	
	public DTOUser getUs() {
		us = ubr.getUser(sId);
		return us;
	}

	public void setUs(DTOUser us) {
		this.us = us;
	}

	public Integer getsId() {
		return sId;
	}

	public void setsId(Integer sId) {
		this.sId = sId;
	}
	
	public void attributeListener(ActionEvent event){ 
		sId = (Integer) event.getComponent().getAttributes().get("cUser");
		this.us = ubr.getUser(sId);
	}
	
}
